<template>
  <div>MyView</div>
  <el-dialog
    v-model="dialogVisibled"
    title="新增"
    width="500px"
    :before-close="handleClose"
    :align-center="true"
  >
    <template #footer>
      <el-button type="primary" @click="closeDialog">确定</el-button>
      <el-button @click="closeDialog"> 取消 </el-button>
    </template>
  </el-dialog>
</template>

<script lang="ts">
import { defineComponent, computed } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
export default defineComponent({
  props: ["isDialog", "closeDialog"],
  name: "MyView",
  setup(props) {
    const handleClose = () => {
      ElMessageBox.confirm("是否确实要关闭此对话框", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          props.closeDialog();
          ElMessage({
            type: "success",
            message: "添加成功",
          });
        })
        .catch(() => {
          // ElMessage({
          //   type: "info",
          //   message: "Delete canceled",
          // });
        });
    };
    const dialogVisibled = computed(() => {
      return props.isDialog;
    });
    return { handleClose, dialogVisibled };
  },
});
</script>

<style lang="scss" scoped>
</style>